<%--
  Created by IntelliJ IDEA.
  User: nguyentrongduy
  Date: 17/8/12
  Time: 4:44 PM
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <meta name="layout" content="main">
    <title></title>
</head>
<body>

<g:render template="/vatLieu/createEditVatLieu/header" model="['step':1]"></g:render>
<g:render template="/includes/includeUploadify" />

<g:if test="${flash.message}">
    <div class="message" role="status">${flash.message}</div>
</g:if>

<g:hasErrors bean="${vatLieu}">

    <ul class="errors" role="alert">
        <g:eachError bean="${vatLieu}" var="error">
            <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
        </g:eachError>
    </ul>
</g:hasErrors>

<g:form>
    <div>
        <table>
            <tr>
                <td>
                    <g:message code="vatLieu.ten.label"></g:message>
                </td>
                <td>
                    <input name="ten" value="${vatLieu?.ten}" size="30"/>
                </td>
            </tr>
            <tr>
                <td>
                    <g:message code="vatLieu.anh.label"></g:message>
                </td>
                <td>
                    <img src="${dl.getVatLieuPhoto(['getThumb':true, 'vatLieu':vatLieu])}" alt="" id="vatLieuAvatarImage"  width="100" height="100" />

                    <input id="vatLieuAvatarUrl" name="avatarUrl" type="hidden" value="${dl.getVatLieuPhoto(['getThumb':true, 'vatLieu':vatLieu])}}" />
                    <input id="avatarChanged" name="avatarChanged"  type="hidden" value="false" />

                    <dl:uploadify  class=""
                                   name="uploadAvatar"
                                   action= "${request.contextPath}/utils/uploadSanPhamAvatar"
                                   label="${message(code:'button.uploadBGImage')} : "
                                   multi = 'false'
                                   fileExt="*.jpg; *.png; *.gif"
                                   sizeLimit="${2048*2048}"
                                   onComplete="avatarOnComplete(response)"
                                   onProgress="myOnProgress(event, qId, fileObj, qData)"
                                   delay="500"
                    >
                    </dl:uploadify>


                    <g:javascript>

                        function avatarOnComplete(data){
                            $('#vatLieuAvatarImage').attr('src', data);
                            $('#vatLieuAvatarUrl').val(data);
                            $("#avatarChanged").val(true);
                        };

                    </g:javascript>


                </td>
            </tr>

            <tr>
                <td>
                    <g:message code="vatLieu.chatLieu.label"></g:message>
                </td>
                <td>
                    <input name="chatLieu" value="${vatLieu?.chatLieu}" size="10"/>
                </td>
            </tr>

            <tr>
                <td>
                    <g:message code="vatLieu.doDay.label"></g:message>
                </td>
                <td>

                    <input  class="marginRightStd" name="doDay" value="${vatLieu?.doDay}" size="10"/>

                    <g:select name="doDayDonvi"
                              from="${['mm','m']}"
                              value="${vatLieu?.doDayDonvi}">
                    </g:select>
                </td>
            </tr>

            <tr>
                <td>
                    <g:message code="vatLieu.chieuDai.label"></g:message>
                </td>
                <td>
                    <input class="marginRightStd" name="chieuDai" value="${vatLieu?.chieuDai}" size="10"/>

                    <g:select name="chieuDaiDonvi"
                              from="${['mm','m']}"
                              value="${vatLieu?.chieuDaiDonvi}" />
                </td>
            </tr>

            <tr>
                <td>
                    <g:message code="vatLieu.chieuRong.label"></g:message>
                </td>
                <td>
                    <input class="marginRightStd" name="chieuRong" value="${vatLieu?.chieuRong}" size="10"/>
                    <g:select name="chieuRongDonvi"
                              from="${['mm','m']}"
                              value="${vatLieu?.chieuRongDonvi}">
                    </g:select>
                </td>
            </tr>

            <tr>
                <td>
                    <g:message code="vatLieu.dangCuon.label"></g:message>
                </td>
                <td>
                    <g:checkBox name="dangCuon" checked="${(vatLieu?.dangCuon)?'checked':''}"  ></g:checkBox>
                </td>
            </tr>

            <tr>
                <td>
                    <g:message code="vatLieu.dacDiem.label"></g:message>
                </td>

                <td> <g:textArea name="dacDiem" rows="20" cols="8">${vatLieu?.dacDiem}</g:textArea></td>
            </tr>
        </table>

        <fieldset class="buttons marginTopMiddle">
            <g:submitButton name="huy" class="cancel" value="${message(code:'button.huy')}" />
            <g:submitButton name="tiep" class="save" value="${message(code:'button.tieptuc')}" />
        </fieldset>
    </div>
</g:form>


</body>
</html>